<template>
  <div class="address">
    <div class="header">
      <span class="title">收货地址</span>
    </div>
    <div class="reaceaddress">
      <ul>
        <li class="place" v-for="item in list" :key="item.id">
          <div class="placetop">
            <span class="name">{{item.receiveName}}</span>
            <span class="phonenum">{{item.receivePhone}}</span>
          </div>
          <div class="detailplace">{{item.receiveAddr}}</div>
          <div class="icons" v-if="isDefault">默</div>
          <div v-else></div>
          <div class="right" @click="go(item)">编辑</div>
        </li>
      </ul>
      <div class="newaddress" @click="goto()">
        新增收获地址
        <img :src="images5" class="images5">
      </div>
    </div>
  </div>
</template>

<script>
import pic4 from "../../icons/left2.png";
import pic5 from "../../icons/right.png";
import * as api from "../../request/api.js";
export default {
  name: "Address",
  data() {
    return {
      images4: pic4,
      images5: pic5,
      list: "",
      isDefault:true,

    };
  },
  created() {
    this.$http
      .post(api.ADDRESSLIST, {
        data: {
          pageNo: 1,
          pageSize: 10
        }
      })
      .then(resp => {
        console.log(resp);
        this.list = resp.data.data;
         resp.data.data.forEach(item => {
           console.log(item.isDefault)
         });
      }) .catch(resp => {});
      console.log(this.isDefault)
     
  },
  methods: {
    go(item) {
      this.$router.push({
        path: "/modifyplace",
        query: {
          id: item.id,
          receiveName: item.receiveName,
          receivePhone: item.receivePhone,
          receiveAddr: item.receiveAddr
        }
      });
    },
    goto() {
      this.$router.push({ path: "./chooseplace" });
    },

  }
};
</script>

<style lang="less" scoped>
@import "../../less/address.less";
</style>
